package com.Zhengxin.bean;


import java.util.Calendar;

import com.Zhengxin.receiver.CallAlarm;

import android.app.AlarmManager;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class SetAlarm {
	private int alarmTime;
	private Calendar calendar= Calendar.getInstance();
	public SetAlarm(Context contexts){
		System.out.println("set new alarm clock start");
		FindNewAlarm fna=new FindNewAlarm(contexts);
		alarmTime=fna.find();
//		Calendar calendar= Calendar.getInstance();
//		calendar.getTimeInMillis();
//		//calender.set(Calendar.DAY_OF_WEEK,Integer.parseInt(alarmTime.substring(0)));
//		calendar.set(Calendar.HOUR_OF_DAY, 12);
//		calendar.set(Calendar.MINUTE, 15);
//		
		Intent intent=new Intent(contexts,CallAlarm.class);
		PendingIntent sender=PendingIntent.getBroadcast(contexts, 0, intent, 0);
		AlarmManager am;
		am = (AlarmManager)contexts.getSystemService(contexts.ALARM_SERVICE);
		am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis()+(alarmTime*1000), sender);
		
		System.out.println("set new alarm clock end");
		return;
	}
}
